package cn.xyinping.hrm.service.impl;

import cn.xyinping.hrm.constans.BasicConstans;
import cn.xyinping.hrm.domain.Meal;
import cn.xyinping.hrm.mapper.MealMapper;
import cn.xyinping.hrm.service.IMealService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 * 套餐表 服务实现类
 * </p>
 *
 * @author xyinping
 * @since 2021-11-22
 */
@Service
public class MealServiceImpl extends ServiceImpl<MealMapper, Meal> implements IMealService {
    @Autowired
    private MealMapper mealMapper;
    @Override
    public void saveRelationLogin(long mealId, Long loginId) {
        // 使用7天
        Date date = DateUtils.addDays(new Date(), 7);
        mealMapper.saveRelationLogin(
                mealId, // 套餐Id
                loginId, // 机构管理员
                date, // 套餐试用结束
                BasicConstans.Meal.STATE_UN_PAY); // 状态：未支付
    }
}
